<!DOCTYPE html>
<html lang="en" xmlns:th="http://thymeleaf.org">
<head>
    <head>
        <th:block th:include="include :: header('用户列表')"/>
    </head>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="searchForm">
                <div class="select-list">
                    <ul>
                        <li>
                            登录名：<input type="text" id="loginName"/>
                        </li>
                        <li>
                            用户名：<input type="text" id="userName"/>
                        </li>
                        <li>
                            手机号：<input type="text" id="phone"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" id="searchButton"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" id="resetButton"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary single disabled" onclick="selectOk();">
                <i class="fa fa-check"></i> 确认选择
            </a>
            <button class="btn btn-danger" type="button" onclick="cancel()">
                <i class="fa fa-reply-all"></i>关闭
            </button>

        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="dataTable"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<!-- jquery-validate 表单树插件 -->
<script type="text/javascript" th:inline="javascript">
    let $table;
    $(function () {
        loadData();

    });


    function loadData(){
        let options={
            url: '/admin/sysuser/getUserList',
            pageNumber: 1,                      // 初始化加载第一页，默认第一页,并记录
            pageSize: 10,                       // 每页的记录行数（*）
            pageList: "10, 25, 50, 100",        // 可供选择的每页的行数（*）
            queryParams: function (params) {
                let p = {
                    pageNumber: params.pageNumber,
                    pageSize: params.pageSize,
                    loginName:$('#loginName').val(),
                    userName:$('#userName').val(),
                    phone:$('#phone').val()
                }
                return p;
            },
            columns: [
                {field: 'selectItem', radio:true},
                {
                    field: 'loginName', title: '登录账号', align: "center"
                },
                {field: 'userName', title: '用户名', align: "center"},
                {field: 'mobilePhone', title: '联系电话', align: "center"},
                {field: 'email', title: '邮箱', align: "center"},

            ]
        };

        $table=$('#dataTable').easyTable(options);
        $table.easyTable('selectedEvent');
    }




    function selectOk(){
        const rows=$table.easyTable("selected");
        if(rows.length==0){
            jutils.warn("请选择数据行");
            return;
        }

        jutils.postMessage('userSelect',rows[0]);
        cancel();
    }

   function cancel(){
       jutils.closeDialog();
   }
</script>
</body>
</html>